package org.metis4j.framework;

import org.metis4j.framework.core.ClassScanner;
import org.metis4j.framework.core.impl.DefaultClassScanner;
import org.metis4j.framework.mvc.Handler;
import org.metis4j.framework.mvc.HandlerExceptionResolver;
import org.metis4j.framework.mvc.HandlerInvoker;
import org.metis4j.framework.mvc.HandlerMapping;
import org.metis4j.framework.mvc.ViewResolver;
import org.metis4j.framework.mvc.impl.DefaultHandlerExceptionResolver;
import org.metis4j.framework.mvc.impl.DefaultHandlerInvoker;
import org.metis4j.framework.mvc.impl.DefaultHandlerMapping;
import org.metis4j.framework.mvc.impl.DefaultViewResolver;
import org.metis4j.framework.util.ReflectUtil;

public class InstanceFactory {

	/**
	 * class_scanner
	 */
	private static final String CLASS_SCANNER = "";

	/**
	 * HandlerMapping
	 */
	private static final String HANDLER_MAPPING = "";

	/**
	 * HandlerInvoker
	 */
	private static final String HANDLER_INVOKER = "";

	/**
	 * HandlerExceptionResolver
	 */
	private static final String HANDLER_EXCEPTION_RESOLVER = "";

	/**
	 * ViewResolver
	 */
	private static final String VIEW_RESOLVER = "";

	/**
	 * @return
	 */
	public static ClassScanner getClassScanner() {
		return getInstance(CLASS_SCANNER, DefaultClassScanner.class);
	}

	public static HandlerMapping getHandlerMapping() {
		return getInstance(HANDLER_MAPPING, DefaultHandlerMapping.class);
	}

	public static HandlerInvoker getHandlerInvoker() {
		return getInstance(HANDLER_INVOKER, DefaultHandlerInvoker.class);
	}

	public static HandlerExceptionResolver getHandlerExceptionResolver() {
		return getInstance(HANDLER_EXCEPTION_RESOLVER, DefaultHandlerExceptionResolver.class);
	}

	public static ViewResolver getViewResolver() {
		return getInstance(VIEW_RESOLVER,DefaultViewResolver.class);
	}

	private static <T> T getInstance(String cLASS_SCANNER, Class<T> defaultClass) {
		// TODO Auto-generated method stub
		T t = ReflectUtil.newInstance(defaultClass.getName());
		return t;
	}

}
